<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="loginform" action="/doLogin" method="post">
    username:<input id="u" type="text" name="username"><br>
    password:<input id="p" type="text" name="password"><br>
<!--    <img src="/common/profile?id=1111" height="44" width="44"><br>-->
    <input name="remember-me" type="checkbox" value="true"/>记住我<br>
    <button id="btn1111111" type="submit" >提交111</button>
</form>

<script src="/js/jquery.min.js"></script>
<script>
    $('#btn').on('click',function(){
        sendRequest();
    })
    function sendRequest() {
        $.ajax({
            url: '/doLogin',
            type: "POST",
            dataType: "json",
            contentType: "application/x-www-form-urlencoded",
            // contentType: "application/json",
            cache: false,
            crossDomain: true,
            xhrFields: {
                withCredentials: true
            },
            data: {"username":$("#u").val(),"password":$("#p").val()},
            success: function(res){
                console.log("res"+JSON.stringify(res));
            },
            error:function(xhr, textStatus, errorThrown){
                console.log("ajax request error")
                /*错误信息处理*/
                console.log("进入error---");
                console.log("状态码："+xhr.status);
                console.log("状态:"+xhr.readyState);//当前状态,0-未初始化，1-正在载入，2-已经载入，3-数据进行交互，4-完成。
                console.log("错误信息:"+xhr.statusText );
                console.log("返回响应信息："+xhr.responseText );//这里是详细的信息
                console.log("请求状态："+textStatus);
                console.log(errorThrown);
                console.log("请求失败")
            }
        });
    }
</script>
</body>
</html>